#pragma once

#include "StringUtils.h"
#include "TestString.h"

namespace TestFramework
{
    const TestString& GetErrorCodePattern();

    const char* FormatErrorText(const TestString& text, int code);
    const char* FormatErrorText(const char* errorDescription, int code);

    void ReplaceSubstring(TestString& input, const TestString& pattern, const TestString& substitution);

    template <typename T1>
    char* FormatErrorMessage(const TestString& pattern, const T1& value1)
    {
      TestString result(pattern);
      ReplaceSubstring(result, "{0}", ToString<TestString>(value1));
      return StrCopy(result.Data());
    }

    template <typename T1, typename T2>
    char* FormatErrorMessage(const TestString& pattern, const T1& value1, const T2& value2)
    {
      TestString result(pattern);
      ReplaceSubstring(result, "{0}", ToString<TestString>(value1));
      ReplaceSubstring(result, "{1}", ToString<TestString>(value2));
      return StrCopy(result.Data());
    }

    template <typename T1, typename T2, typename T3>
    char* FormatErrorMessage(const TestString& pattern, const T1& value1, const T2& value2, const T3& value3)
    {
      TestString result(pattern);
      ReplaceSubstring(result, "{0}", ToString<TestString>(value1));
      ReplaceSubstring(result, "{1}", ToString<TestString>(value2));
      ReplaceSubstring(result, "{3}", ToString<TestString>(value3));
      return StrCopy(result.Data());
    }
}
